# 基于node的官方镜像
FROM node:alpine as build-stage

# 设置工作目录
WORKDIR /app

# 复制package.json和package-lock.json(或yarn.lock)
COPY package*.json ./

# 安装项目依赖
RUN npm install

# 复制项目文件到工作目录
COPY . .

# 全局安装serve
RUN npm install -g serve

# 构建应用
RUN npm run build

# 启动服务
CMD ["serve", "-s", "build", "-l", "80"]